package com.steinwurf.hdcjoinwifi;

import ohos.net.HttpProxy;
import ohos.wifi.WifiDeviceConfig;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;

public class ProxyTest {

    private Proxy proxy;
    private String bypass = "hello world";
    private static final String TAG = "ProxyTest";
    private HttpProxy mHttpProxy;

    private static final Object[] getDatas1() {
        return new Object[]{
                new Object[]{"127.0.0.1", "8080", "hello world", "?hello world"}
        };
    }

    @Before
    public void setUp() throws Exception {
        proxy = new Proxy();
        mHttpProxy = new HttpProxy();
    }

    @After
    public void tearDown() throws Exception {
    }

    @Test
    public void join() {
        String join = proxy.join("hello world", (Iterable) Arrays.asList(bypass.split(",")));
        Assert.assertNotNull(join);
    }

    @Test(expected = Exception.class)
    public void parseProxyInfo() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Method method = proxy.getClass().getDeclaredMethod("parseProxyInfo",String.class,String.class,String.class,String.class);
        method.setAccessible(true);
        HttpProxy httpProxy = (HttpProxy) method.invoke(proxy,"host","port","bypass","pacUri");
    }

    @Test(expected = Exception.class)
    public void setProxy() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Method method1 = proxy.getClass().getDeclaredMethod("setProxy", WifiDeviceConfig.class,HttpProxy.class);
        method1.setAccessible(true);
        method1.invoke(proxy, new WifiDeviceConfig(),new HttpProxy());
    }
}